@extends('admin.mainlayout')
@section('title')
    <div class="title"><span>审核管理</span></div>
    <br/>
    <div class="main_top" >
        <form id='search' action="{{urlAdmin('Brand','getApply')}}" method="get">
            <span>选择时间段</span>
            <input type="text" name="starttime" class="laydate-icon" id="hello2"/><span>到</span>
            <input type="text" name="endtime" class="laydate-icon" id="hello3"/>
            <input type="text" name="keyword" style="width: 120px;height: 21px;margin-left: 100px" placeholder="手机号/负责人"/>
            <input type="hidden" name="status" value="<?php echo $_GET['status']; ?>">
            <span id="sousuo" >搜索</span>
        </form>
    </div>
    <style type="text/css">
        #sousuo{
            display:inline-block;
            background: #347c1e;
            text-align: center;
            color:white;
            height:25px;
            width:40px;
            margin-left: 40px;
            cursor: pointer;
        }
        #sousuo:hover{
            background-color: #2d94e8;
        }

    </style>
    @endsection
    @section('content')
            <!-- start 审核管理-->
    <div class="one">
        <div class="tab">
            <p @if($_GET['status']==0)class="active"@endif><a href="/center/brand/apply?status=0">待审核</a></p>
            <p @if(isset($_GET['status'])&&$_GET['status']!=0)class="active"@endif><a href="/center/brand/apply?status=1">已审核</a></p>
        </div>
        <table>
            <thead>
            <tr>
                <th>序号</th>
                <th>品牌名称</th>
                <th>负责人</th>
                <th>联系方式</th>
                <th>区域</th>
                <th>申请时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            @if(!empty($res['data']))
            @foreach($res['data'] as $d)
            <tr id="tr_{{$d['id']}}">
                <td>{{$d['id']}}</td>
                <td>{{$d['title']}}</td>
                <td>{{$d['name']}}</td>
                <td>{{$d['mobile']}}</td>
                <td>{{$d['address']}}</td>
                <td>{{$d['created_at']}}</td>
                <td>
                    @if($d['status']==0)
                    <span class="green" onclick="verify(1,{{$d['id']}})">通过</span>
                    <span class="red"  onclick="verify(2,{{$d['id']}})">不通过</span>
                    @endif
                    @if($d['status']==1)
                            <span class="green">已通过</span>
                            <span class="red" onclick="del({{$d['id']}})">删除</span>
                    @endif
                    @if($d['status']==2)
                            <span class="red">驳回</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <span class="red" onclick="del({{$d['id']}})">删除</span>
                    @endif
                </td>
            </tr>
            @endforeach
             @endif
            </tbody>
        </table>
        <div class="del">
            <div class="bot">
                @if($res['prev_page_url'])
                <p class="prev"><a href="{{$res['prev_page_url']}}">上一页</a></p>
                 @endif
                <ul>
                    @foreach($res['pageNoList'] as $v)
                    <li @if($res['current_page'] ==  $v )class="active_list" @endif ><a href="/center/brand/apply?@if(isset($_GET['status']))status={{$_GET['status']}}@endif&page={{$v}}">{{$v}}</a></li>
                    @endforeach
                </ul>
                @if($res['next_page_url'])
                     <p class="next"><a href="{{$res['next_page_url']}}">下一页</a></p>
                 @endif
            </div>
        </div>
    </div>
@endsection
<script>
    //单个删除
    function del(id){

        layer.confirm('确定要删除该项吗?',{btn:['确定','取消']},function(){
            layer.closeAll();
            //alert(id);
            $.ajax({
                type:'get',
                url:"{{urlAdmin('Brand','getDel')}}",
                data:{id:id},
                dataType:'json',
                success: function (res) {


                    if(res['status']==1){

                        layer.msg(res.msg,{icon:6});
                        setTimeout("location.reload()",1500);

                    }else{

                        layer.msg(res.msg,{icon:5});

                    }

                }

            });

        },function(){

            layer.msg('你取消了!');

        });
    }


    function verify(m,id) {
        layer.confirm('您确定该操作吗？', {
            btn: ['确定', '取消'] //按钮
        }, function () {
            $.ajax({
                type: "post",
                url: "/center/brand/verify",
                data:{id:id,status:m},
                dataType: "json",
                success: function (res) {
                    if (res['status'] == 1) {
                        layer.msg('操作成功', {icon: 6});
                        $('#tr_'+id).hide();
                    } else {
                        layer.msg('操作失败', {icon: 5});
                    }
                }
            })

        });
    }
    window.onload = function(){

        //时间搜索
        var oSousuo = document.getElementById('sousuo');
        var oSearch = document.getElementById('search');

        oSousuo.onclick = function(){
            //加载效果
            layer.load(2, {shade: false});
            oSearch.submit();

        }

        laydate({
            elem: '#hello2'
        });
        laydate({
            elem: '#hello3'
        });

    }
</script>